<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class DocumentArticle extends Model
{
    protected $connection = 'mysql_pclady';
    protected $table = 'document_article';

    public function getInfo($id){
        $res = $this->where('document_article.id',$id)->select('document.id','title','description','content','create_time')
            ->join('document', 'document_article.id', '=', 'document.id')
            ->get();
        foreach ($res as $key => $obj){
            $obj->title = preg_replace('/_(.*?)/','',$obj->title);
            $obj->content = preg_replace('/(\(图片(.*?)\)|\（图片(.*?)\）)/si','', $obj->content);
            $obj->content = preg_replace('/\（图片(.*?)\)/si','', $obj->content);
            $obj->content = str_replace('点击图片进入下一页>>','', $obj->content);
            $obj->content = str_replace('点击图片进入下一页&gt;&gt;','', $obj->content);
        }
        return $res[0];
    }
}
